from django.db import models

class device_information(models.Model):
    ip_address = models.CharField(max_length=255)
    hostname = models. CharField(max_length=255)
    username = models.CharField (max_length=255)
    password = models.CharField (max_length=255) #字符串字段
    port = models.IntegerField(default=22) #整数字段

    VENDOR_CHOICES = (  # 元组
        ('huawei', '华为'),
        ('cisco', 'Cisco'),
    )
    vendor = models.CharField(max_length=255, choices=VENDOR_CHOICES)  # choices赋予下拉列表

    def __str__(self): #定义，当被 str() 调用时，也就是网页请求admin后台此models名称时
        return f"{self.id}. {self.ip_address}.{self.vendor}" #return特点名称

class Log(models.Model): #日志
    target = models.CharField(max_length=255) #操作目标
    action = models.CharField(max_length=255) #操作行为
    status = models.CharField(max_length=255) #事件状态成功与否
    time = models.DateTimeField(null=True) #操作事件
    message = models.CharField(max_length=255,blank=True) #blank=True，表示该字段为空也允许

